package org.jsola.hr.helper;

import org.jsola.common.SafeKit;
import org.jsola.hr.dto.TransferAccountsZfbSafetyDetailAddDTO;
import org.jsola.hr.dto.TransferAccountsZfbSafetyDetailUpdateDTO;
import org.jsola.hr.entity.TransferAccountsZfbSafetyDetailDO;
import org.jsola.hr.query.TransferAccountsZfbSafetyDetailQuery;
import org.jsola.hr.service.ITransferAccountsZfbSafetyDetailService;
import org.jsola.hr.vo.TransferAccountsZfbSafetyDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 安全发转账明细(支付宝)
 *
 * @author zhr
 */
@Component
public class TransferAccountsZfbSafetyDetailTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsZfbSafetyDetailService transferAccountsZfbSafetyDetailService;

    /**
     * 生成add测试数据
     * @return TransferAccountsZfbSafetyDetailAddDTO
     */
    public TransferAccountsZfbSafetyDetailAddDTO getTransferAccountsZfbSafetyDetailAddDTO(){
        TransferAccountsZfbSafetyDetailAddDTO transferAccountsZfbSafetyDetailAddDTO = new TransferAccountsZfbSafetyDetailAddDTO();
        transferAccountsZfbSafetyDetailAddDTO.setTransAmountAll(getRandomValue("varchar",16));
        transferAccountsZfbSafetyDetailAddDTO.setAccountBookId(getRandomValue("varchar",64));
        transferAccountsZfbSafetyDetailAddDTO.setAgreementNo(getRandomValue("varchar",256));
        transferAccountsZfbSafetyDetailAddDTO.setOrderTitle(getRandomValue("varchar",32));
        transferAccountsZfbSafetyDetailAddDTO.setRemark(getRandomValue("varchar",32));
        transferAccountsZfbSafetyDetailAddDTO.setIdentityType(getRandomValue("varchar",64));
        transferAccountsZfbSafetyDetailAddDTO.setIdentity(getRandomValue("varchar",64));
        transferAccountsZfbSafetyDetailAddDTO.setName(getRandomValue("varchar",256));
        transferAccountsZfbSafetyDetailAddDTO.setSafetyBatchId(getRandomValue("varchar",32));
        transferAccountsZfbSafetyDetailAddDTO.setOrderId(getRandomValue("varchar",32));
        transferAccountsZfbSafetyDetailAddDTO.setPayFundOrderId(getRandomValue("varchar",32));
        transferAccountsZfbSafetyDetailAddDTO.setTransAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        transferAccountsZfbSafetyDetailAddDTO.setStatus(getRandomValue("varchar",64));
        transferAccountsZfbSafetyDetailAddDTO.setPayDate(getRandomValue("varchar",20));
        transferAccountsZfbSafetyDetailAddDTO.setArrivalTimeEnd(getRandomValue("varchar",20));
        transferAccountsZfbSafetyDetailAddDTO.setOrderFee(getRandomValue("varchar",20));
        transferAccountsZfbSafetyDetailAddDTO.setErrorCode(getRandomValue("varchar",64));
        transferAccountsZfbSafetyDetailAddDTO.setFailReason(getRandomValue("varchar",128));
        return transferAccountsZfbSafetyDetailAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsZfbSafetyDetailUpdateDTO
     */
    public TransferAccountsZfbSafetyDetailUpdateDTO getTransferAccountsZfbSafetyDetailUpdateDTO(TransferAccountsZfbSafetyDetailVO transferAccountsZfbSafetyDetailVO){
        return transferAccountsZfbSafetyDetailService.selectDOById(transferAccountsZfbSafetyDetailVO.getId(), SITE_ID).to(TransferAccountsZfbSafetyDetailUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsZfbSafetyDetailQuery
     */
    public TransferAccountsZfbSafetyDetailQuery getTransferAccountsZfbSafetyDetailQuery() {
        TransferAccountsZfbSafetyDetailQuery transferAccountsZfbSafetyDetailQuery = new TransferAccountsZfbSafetyDetailQuery();
        List<TransferAccountsZfbSafetyDetailDO> transferAccountsZfbSafetyDetailDOList = transferAccountsZfbSafetyDetailService.list(new TransferAccountsZfbSafetyDetailDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsZfbSafetyDetailDOList)) {
            TransferAccountsZfbSafetyDetailDO transferAccountsZfbSafetyDetailDO = transferAccountsZfbSafetyDetailDOList.get(0);
            transferAccountsZfbSafetyDetailQuery = transferAccountsZfbSafetyDetailDO.to(TransferAccountsZfbSafetyDetailQuery.class);
        }
        return transferAccountsZfbSafetyDetailQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsZfbSafetyDetailVO
     */
    public TransferAccountsZfbSafetyDetailVO saveTransferAccountsZfbSafetyDetailExample(){
        TransferAccountsZfbSafetyDetailAddDTO addDTO = this.getTransferAccountsZfbSafetyDetailAddDTO();
        TransferAccountsZfbSafetyDetailVO transferAccountsZfbSafetyDetailVO = transferAccountsZfbSafetyDetailService.save(addDTO,buildTokenUser());
        return transferAccountsZfbSafetyDetailVO;
    }


}

